home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / local / wowConfig.php < prev   
PHP Script  |  2010-05-19  |  20KB  |  591 lines

  1. <?php
  2. /**
  3.  * Wake on Wan configuration script
  4.  *
  5.  * config format: $wowEnabled:$useHost:mackPack($mac):port:[$host]
  6.  * 0/1 $wowEnabled: is wake on wan enabled
  7.  * 0/1 $useHost: 1 to use hostname instead of last known IP
  8.  * string(8) mackPack($mac): packed MAC
  9.  * string(3) port: base64 encoded 16bits port
  10.  * string(0-40) host (conditional): host name
  11.  *
  12.  *
  13.  * PHP version 5
  14.  *
  15.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  16.  * that is available through the world-wide-web at the following URI:
  17.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  18.  * the PHP License and are unable to obtain it through the web, please
  19.  * send a note to license@php.net so we can mail you a copy immediately.
  20.  *
  21.  * @category   NA
  22.  * @package    NA
  23.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  24.  * @copyright  2005-2008 Nicolas Bruley / Peer 2 World
  25.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  26.  * @version    CVS: $Id:$
  27.  * @link       http://www.weezo.net
  28.  * @since      File available since Release 1.1.2
  29.  */
  30.  
  31. require(INCLUDE_DIR.'outputFunctions.php');
  32. $_ENV['configurationEnvironment']='application';
  33. define('HOST_MAX_LENGTH',30);
  34.  
  35. /**
  36.  * @desc Check, pack and b64 encode MAC address
  37.  *
  38.  * @param string $mac: MAC address formated like: XX-XX-XX-XX-XX-XX or XX:XX:XX:XX:XX:XX
  39.  * @return string packed mack or false if format is incorrect
  40.  */
  41. function macPack($mac){
  42.     // Check MAC format
  43.     if(preg_match("/^([0-9a-fA-F]{1,2}-){5}[0-9a-fA-F]{1,2}$/",$mac)) $mac=explode('-',$mac);
  44.     elseif(preg_match("/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/",$mac)) $mac=explode(':',$mac);
  45.     else return false;
  46.     $macPack=''; foreach ($mac as $m) $macPack.=chr(hexdec($m));
  47.     return base64_encode($macPack);
  48. }
  49.  
  50. /**
  51.  * @desc b64 decode and Unpack MAC address (see above)
  52.  *
  53.  * @param string $packed
  54.  * @return string
  55.  */
  56. function macUnpack($packed){
  57.     if(strlen($packed=base64_decode($packed))!=6) return false;
  58.     $unpacked=((ord($packed[0])<16)?'0':'').dechex(ord($packed[0]));
  59.     for($i=1;$i<6;$i++) $unpacked.='-'.((ord($packed[$i])<16)?'0':'').dechex(ord($packed[$i]));
  60.     return strtoupper($unpacked);
  61. }
  62.  
  63. /**
  64.  * @desc Check if host format is ok
  65.  *
  66.  * @param string $host
  67.  * @return boolean
  68.  */
  69. function checkHost($host){
  70.     if(preg_match("/^[a-zA-Z0-9\.-]{4,".HOST_MAX_LENGTH."}$/",$host) && strpos($host,'.')>0 && strrpos($host,'.')<strlen($host)-2)    return true;
  71.     return false;
  72. }
  73.  
  74. /**
  75.  * @desc Shutdown UDP listening socket
  76.  *
  77.  */
  78. function shutdownSocket(){
  79.     global $serverSock;
  80.     @socket_close($serverSock);
  81.     //cfDbg('Socket shutdown',1);
  82. }
  83.  
  84.  
  85. // Don't know how it did ever work, but everything is coded with GET whereas sendData (may) use POST
  86. if(count($_POST)) $_GET=$_POST;
  87.  
  88.  
  89. /*
  90.  ***************************************************************************************************************************
  91.  * Parse network adapters
  92.  ***************************************************************************************************************************
  93.  */
  94. $adapters=array();
  95. if(isset($_GET['adapters']) && $_GET['adapters']) foreach (explode('/',base64_decode($_GET['adapters'])) as $adapter){
  96.     if(count(explode(':',$adapter))==3)
  97.         @list($mac,$name,$traffic)=explode(':',$adapter);
  98.     elseif(count(explode(':',$adapter))==2){
  99.         @list($mac,$name)=explode(':',$adapter);
  100.         $traffic=0;
  101.     }
  102.     else
  103.         continue;
  104.  
  105.     $mac=macUnpack(macPack($mac));
  106.     if(!$mac) continue;
  107.  
  108.     // If adapter already defined
  109.     if(isset($adapters[$mac])){
  110.         if(strlen($name)<strlen($adapters[$mac]['name'])) $adapters[$mac]['name']=$name;
  111.         $adapters[$mac]['traffic']+=$traffic;
  112.     }
  113.     else $adapters[$mac]=array('name'=>$name,'traffic'=>$traffic);
  114.  
  115.     // Lower priority of VMWare adapters
  116.     if(stripos($adapters[$mac]['name'],'vmware')!==false) $adapters[$mac]['traffic']=0;
  117. }
  118.  
  119.  
  120. /*
  121.  ***************************************************************************************************************************
  122.  * Parse configuration
  123.  ***************************************************************************************************************************
  124.  */
  125. if(isset($_GET['config']) && strlen($_GET['config'])>=18 && count(explode(':',$_GET['config']))==5){
  126.     list($wowEnabled,$wowUseHost,$wowMac,$wowPort,$wowHost)=explode(':',$_GET['config']);
  127.     $wowMac=macUnpack($wowMac);
  128.     $wowPort=unpack('S',base64_decode($wowPort));$wowPort=$wowPort[1];
  129. }
  130. else{
  131.     $wowEnabled=((isset($_GET['config']) && $_GET['config']=='1:')?1:0); // Set default enabled if user clicked on enable WOW with empty config
  132.     $wowUseHost=0;
  133.     $wowMac='  -  -  -  -  -  ';
  134.  
  135.     // Select default network adapter (use the one with most traffic)
  136.     $maxTraffic=-1;
  137.     foreach ($adapters as $mac=>$adapter) if(@$adapter['traffic']>$maxTraffic){
  138.         $maxTraffic=$adapter['traffic'];
  139.         $wowMac=$mac;
  140.     }
  141.     $wowPort=cfGGetVar('serverPort');
  142.     $wowHost='';
  143. }
  144.  
  145. /*
  146.  ***************************************************************************************************************************
  147.  * Process GET commands
  148.  ***************************************************************************************************************************
  149.  */
  150. if(isset($_GET['wowForm'])){
  151.  
  152.     $configOK=true;
  153.  
  154.     // WOW enabled
  155.     $wowEnabled=((isset($_GET['wowEnabled']))?'1':'0');
  156.     $config=$wowEnabled.':';
  157.  
  158.     // Use host name instead of IP
  159.     $config.=($wowUseHost=(((isset($_GET['wowUseHost']) && $_GET['wowUseHost']=='true'))?'1':'0')).':';
  160.  
  161.     // MAC
  162.     if(!isset($_GET['wowAdapter']) || $_GET['wowAdapter']=='other') {
  163.         if(isset($_GET['wowMac0'])){
  164.             $wowMac=$_GET['wowMac0'];
  165.             for($i=1;$i<6;$i++) $wowMac.='-'.$_GET['wowMac'.$i];
  166.         }
  167.         else $wowMac=' - - - - - ';
  168.     }
  169.     else $wowMac=$_GET['wowAdapter'];
  170.     if(macPack($wowMac)) $config.=macPack($wowMac).':'; else $configOK=false;
  171.  
  172.     // Port
  173.     if(isset($_GET['wowPort'])){
  174.         $wowPort=$_GET['wowPort'];
  175.         $config.=base64_encode(pack('S',$wowPort)).':';
  176.     }
  177.     else $wowPort='';
  178.  
  179.  
  180.     // Host name
  181.     if(isset($_GET['wowHost']) && $_GET['wowHost']){
  182.         if(checkHost($_GET['wowHost'])) {
  183.             $wowHost=strtolower($_GET['wowHost']);
  184.             $config.=$wowHost;
  185.         }
  186.         else $configOK=false;
  187.     }
  188.  
  189.     // Full test
  190.     $wowFullTest =(isset($_GET['testFull']) && $_GET['testFull']);
  191.  
  192.     /**
  193.      * Async Request: perform WOW simple test
  194.      */
  195.     if(cfIsAsync()){
  196.         echo cfAsyncHeader();
  197.  
  198.         // If using hostname, first resolve
  199.         if($wowUseHost){
  200.             $ip=@gethostbyname($wowHost);
  201.             // If hostname couldn't be resolved
  202.             if(!$ip || $ip==$wowHost){
  203.                 echo cfAsyncXMLJSaction('dgi("wowHost").style.color="red"');
  204.                 echo cfAsyncXMLJSaction('setTestResult("'.cfCaption('wowUnknownHost').'",1,"'.outIcon('warning').'")');
  205.                 die(cfAsyncFooter());
  206.             }
  207.             // If resolved hostname ip doesn't match with client IP
  208.             if(isset($_GET['externalIP']) && $ip!=$_GET['externalIP']){
  209.                 echo cfAsyncXMLJSaction('dgi("wowHost").style.color="red"');
  210.                 echo cfAsyncXMLJSaction('setTestResult("'.cfCaption('wowHostNotMatchingIP').'",1,"'.outIcon('warning').'")');
  211.                 die(cfAsyncFooter());
  212.             }
  213.         }
  214.         // Open local UDP listening socket
  215.         if(!($serverSock = @socket_create(AF_INET,SOCK_DGRAM,SOL_UDP)) || (!@socket_bind($serverSock, 0, $wowPort))) {
  216.             echo cfAsyncXMLJSaction('wowTestSocketError("Socket error, UDP port '.$wowPort.' seems to be used")');
  217.             @socket_close($serverSock);
  218.             die(cfAsyncFooter());
  219.         }
  220.         socket_set_nonblock($serverSock);
  221.         register_shutdown_function('shutdownSocket');
  222.  
  223.  
  224.         // Ask weezo server a magic packet
  225.         $serverResult=cfSocketHTTPRequest('http://weezo.net/wow.php?api=1&mac='.$wowMac.'&port='.$wowPort);
  226.  
  227.         // Problem sendign UDP packet
  228.         if($serverResult!='OK') {
  229.             echo cfAsyncXMLJSaction('setTestResult("'.cfCaption('serverError').'",1)');
  230.             die(cfAsyncFooter());
  231.         }
  232.  
  233.         // wait for incoming packet
  234.  
  235.         // Wait for UDP packet...
  236.         while($i<40){ // 3s
  237.             //echo $i++.(($i%10==0)?'<br>':'.'); flush();
  238.             if($src = @socket_recv($serverSock, $data, 200, 0)) {
  239.                 for($o=0;$o<6;$o++) if(ord($data[$o])!=255) break;
  240.                 if($o==6)     {
  241.                     echo cfAsyncXMLJSaction('wowTestSuccess()');
  242.                     echo cfAsyncFooter();
  243.                     exit;
  244.                 }
  245.             }
  246.             usleep(100000);
  247.             $i++;
  248.         }
  249.  
  250.         echo cfAsyncXMLJSaction('wowTestFailure()');
  251.         die(cfAsyncFooter());
  252.     }
  253.  
  254.     /**
  255.      * Close window and send config to application (prepend a "$:" if a full test must be performed
  256.      */
  257.     if($configOK||!$wowEnabled) {
  258.         cfInsertHEAD();
  259.         //$config=str_replace('+','*weezoPlus*',$config);
  260.  
  261.         die('<body onload="wl.UICommand(\'close\',\''.(($wowFullTest)?'$:':'').$config.'\')"></body>');
  262.     }
  263. }
  264.  
  265.  
  266. /*
  267.  ***************************************************************************************************************************
  268.  * Insert HEAD, JS functions and form
  269.  ***************************************************************************************************************************
  270.  */
  271. cfInsertHEAD(false);
  272. echo cfScriptLink('winClient.js');
  273. ?>
  274. <meta width="490x360"></meta>
  275. <meta title="<?php echo cfCaption('genConfigure');?>"></meta>
  276. <script type="text/javascript">
  277. // Check all fields
  278. function checkAll(){
  279.     // WOW enabled
  280.     dgn("wowEnabled").checked=true;
  281.     if(dgn("wowEnabled").checked) dis='';
  282.     // WOW disabled
  283.     else dis='disabled';
  284.     dgn("wowUseHost",0).disabled=dis;
  285.     dgn("wowUseHost",1).disabled=dis;
  286.     dgn("wowHost").disabled=dis;
  287.     dgn("wowPort").disabled=dis;
  288.     dgn("wowAdapter").disabled=dis;
  289.     for(var i=0;i<6;i++) dgn('wowMac'+i).disabled=dis;
  290.  
  291.     // Enable/disable controls, set error fields
  292.     macOK(); portOK(); hostOK();
  293.     if(dgn("wowEnabled").checked && (!macOK() || !portOK() || !hostOK())){
  294.         wl.button.disable('testBt');
  295.         wl.button.disable('testFullBt');
  296.         wl.button.disable('validateBt');
  297.         return 0;
  298.     }
  299.  
  300.     if(dgn("wowEnabled").checked) wl.button.enable('testBt'); else wl.button.disable('testBt');
  301.     if(dgn("wowEnabled").checked) wl.button.enable('testFullBt'); else wl.button.disable('testFullBt');
  302.     wl.button.enable('validateBt');
  303.     return 1;
  304. }
  305. // Click on validate button
  306. function validate(){
  307.     if(!checkAll()) return;
  308.     dgn('wowHost').enabled='enabled';
  309.     D.wowForm.submit();
  310. }
  311.  
  312. // Check MAC
  313. function macOK(){
  314.     var macOK=true;
  315.  
  316.     for(var i=0;i<6;i++) {
  317.         dgn('wowMac'+i).disabled=((dgn('wowAdapter').value=='other' && dgn("wowEnabled").checked)?'':'disabled');
  318.  
  319.         if(dgn('wowMac'+i).disabled=='' && !dgn('wowMac'+i).value.match(/^[0-9a-fA-F]{2}$/)){
  320.             dgn('wowMac'+i).style.color='red';
  321.             dgn('wowMac'+i).style.backgroundColor='#FEE';
  322.             macOK=false;
  323.         }
  324.         else{
  325.             dgn('wowMac'+i).style.color='';
  326.             dgn('wowMac'+i).style.backgroundColor='';
  327.         }
  328.     }
  329.  
  330.     return macOK;
  331. }
  332.  
  333. // Check port
  334. function portOK(){
  335.     if(dgn('wowPort').value.match(/^[0-9]{1,5}$/) && dgn('wowPort').value<65536 && dgn('wowPort').value>0){
  336.         dgn('wowPort').style.color='';
  337.         dgn('wowPort').style.background='';
  338.         return true;
  339.     }
  340.     dgn('wowPort').style.color='red';
  341.     dgn('wowPort').style.background='#FEE';
  342.     return false;
  343. }
  344.  
  345. // Check host
  346. function hostOK(){
  347.     if(dgn('wowUseHost',0).checked) dgn('wowHost').disabled='disabled';
  348.     else dgn('wowHost').disabled='';
  349.  
  350.     if(dgn('wowHost').value.match(/^[a-zA-Z0-9\.-]{1,<?php echo HOST_MAX_LENGTH; ?>}$/) && dgn('wowHost').value.indexOf('.')>0 && dgn('wowHost').value.lastIndexOf('.')< dgn('wowHost').value.length-2){
  351.         dgn('wowHost').style.color='';
  352.         dgn('wowHost').style.backgroundColor='';
  353.         return true;
  354.     }
  355.     if(dgn('wowUseHost',1).checked) {
  356.         dgn('wowHost').style.color='red';
  357.         dgn('wowHost').style.backgroundColor='#FEE';
  358.     }
  359.     else{
  360.         dgn('wowHost').style.color='';
  361.         dgn('wowHost').style.backgroundColor='';
  362.     }
  363.     return dgn('wowUseHost',0).checked;
  364. }
  365. // Enable/disable WOW
  366. function wowEnabledChanged(){checkAll();}
  367.  
  368. // Select an adapter
  369. function adapterChanged(){
  370.     if(dgn('wowAdapter').value!='other'){
  371.         var parts=dgn('wowAdapter').value.split('-');
  372.         for(var i=0;i<parts.length;i++) dgn('wowMac'+i).value=parts[i];
  373.     }
  374.     checkAll();
  375. }
  376.  
  377. // Change MAC
  378. function macChanged(){checkAll();}
  379.  
  380. // Display help page
  381. var helpDisplayed=0;
  382. function help(){
  383.     helpDisplayed=1-helpDisplayed;
  384.     dgi('helpFrameTxt').innerHTML=dgi('helpFrameTemplate').innerHTML.replace(/PORT/,dgi('wowPort').value).replace(/<a/gi,'<a class="link"');
  385.     dgi('helpFrame').style.display=(helpDisplayed)?'':'none';
  386.     dgi('configFrame').style.display=(helpDisplayed)?'none':'';
  387. }
  388. // Simple WOW test
  389. var wowTestRun=0;//IE animated gif workaround
  390. function wowTest(){
  391.     if(!checkAll()) return;
  392.     if(!wowTestRun) {dgi('testFrame').style.display='';wowTestRun=1;dgi('testFrame').style.display='none'}
  393.     maskShow(false,true);
  394.     fade(dgi('testFrame'),0,1);
  395.     maskMoveAbove(dgi('testFrame'))
  396.     dgi('wowTestLoadingIcon').style.display='';
  397.     dgi('wowTestResultIcon').style.display='none';
  398.     dgi('testResult').innerHTML='<?php echo cfCaption('accessTesting');?>';
  399.     dgi('testResult').className='';
  400.     asyncSubmitForm("wowForm");
  401. }
  402. function setTestResult(text,isError,iconSrc){
  403.     dgi('wowTestLoadingIcon').style.display='none';
  404.     dgi('testResult').innerHTML=text;
  405.     dgi('testResult').className=(isError)?'warning':'';
  406.     if(iconSrc) {
  407.         dgi('wowTestResultIcon').style.display='';
  408.         dgi('wowTestResultIcon').src=iconSrc;
  409.     }
  410. }
  411. function hideTestFrame(){maskHide(1);fade(dgi('testFrame'),1,0);}
  412. function wowTestSocketError(errStr){setTestResult(errStr,1,"<?php echo outIcon('warning');?>");}
  413. function wowTestSuccess(){setTestResult('<?php echo '<b style="color:#273">'.cfCaption('genOK').'</b>'?>',0,"<?php echo outIcon('ok');?>");}
  414. function wowTestFailure(){setTestResult('<?php echo cfCaption('transfersFailed');?>',1,"<?php echo outIcon('warning');?>");}
  415.  
  416. // Full WOW test
  417. function wowTestFull(){
  418.     if(!checkAll()) return;
  419.     dgn('wowAdapter').style.visibility='hidden';
  420.     maskShow(false,true);
  421.     maskMoveAbove(dgi('testFullFrame'));
  422.     fade(dgi('testFullFrame'),0,1);
  423. }
  424. function hideTestFullFrame(){maskHide(1);fade(dgi('testFullFrame'),1,0);dgn('wowAdapter').style.visibility='visible';}
  425. function fullTestRun(){
  426.     hideTestFullFrame();
  427.     wl.button.setIcon('validateBt','<?php echo outIcon('wowTestFull')?>');
  428.     dgn('testFull').value=1;
  429. }
  430. function fullTestCancel(){
  431.     hideTestFullFrame();
  432.     wl.button.setIcon('validateBt','<?php echo outIcon('ok')?>');
  433.     dgn('testFull').value=0;
  434. }
  435.  
  436. </script>
  437. </head>
  438. <body style="overflow:hidden">
  439. <?php
  440. /**
  441.  * Enable/Disable Wake on Wan
  442.  */
  443. echo '<form name="wowForm" id="wowForm" method="GET" enctype="multipart/form-data">';
  444. echo outDivFrame('frame1');
  445. echo outFrameHeaderTable("frame1Header",cfCaption('accountWOW'),'<div style="display:none"><input name="wowEnabled" type="checkbox" '.(($wowEnabled)?'checked="checked"':'').' onclick="wowEnabledChanged()"> <span onclick="dgn(\'wowEnabled\').checked=((dgn(\'wowEnabled\').checked)?\'\':\'checked\');wowEnabledChanged()" style="cursor:default">'.cfCaption('genActivated').'</span>    </div>'.outButton(cfCaption('genHelp'),'javascript:help()',outIcon('help')));
  446. ?>
  447. <br>
  448. <!-- Hidden fields -->
  449. <input name="wowForm" type="text" value="1" style="display:none">
  450. <input name="adapters" type="text" value="<?php echo str_replace('"','',$_GET['adapters']);?>" style="display:none">
  451. <input name="config" type="text" value="<?php echo str_replace('"','',(isset($_GET['config']))?$_GET['config']:'');?>" style="display:none">
  452. <input name="externalIP" type="text" value="<?php echo $_GET['externalIP'];?>" style="display:none">
  453. <input name="testFull" type="text" value="0" style="display:none">
  454.  
  455. <?php
  456.  
  457. /**
  458.  * Help frame
  459.  */
  460. echo '<div id="helpFrame" style="display:none">'.outDivFrame('frame2').'<div class="frame2Header">'.cfCaption('genHelp').'</div><div id="helpFrameTemplate" style="display:none">'.cfCaption('wowHelp','<b>'.'PORT'.'</b>','<b>'.((cfGGetVar('LANIPForced'))?cfGGetVar('LANIPForced'):cfGGetVar('LANIPComputed')).'</b>').'</div>';
  461. echo '<div id="helpFrameTxt"></div><br>';
  462. echo '<center>'.outButton(cfCaption('genClose'),'javascript:help()',outIcon('close')).'</center></div></div>';
  463.  
  464. echo '<div id="configFrame">';
  465.  
  466. /**
  467.  * Host / IP
  468.  */
  469. echo outDivFrame('frame2').'<div class="frame2Header">'.cfCaption('contactURL').'</div>';
  470. ?>
  471.     <span onclick="checkAll()" style="cursor:default"><input type="radio" name="wowUseHost" value="false" <?php echo (($wowUseHost)?'':'checked="checked"');?>>
  472.     <span onclick="dgn('wowUseHost',0).checked='checked'"><?php echo cfCaption('configWOWUseIP'); ?></span></span>
  473.     <br>
  474.     <span onclick="checkAll()" style="cursor:default"><input type="radio" name="wowUseHost" value="true" <?php echo ((!$wowUseHost)?'':'checked="checked"');?>>
  475.     <span onclick="dgn('wowUseHost',1).checked='checked'"><?php echo cfCaption('configWOWUseHost'); ?></span></span><br>
  476.     <input name="wowHost" type="text" value="<?php echo $wowHost; ?>" size="30" maxlength="<?php echo HOST_MAX_LENGTH;?>" onkeyup="checkAll()" style="margin-left:2em">
  477.     <br>
  478. <?php
  479. /**
  480.  * Port
  481.  */
  482. ?>
  483.     <span style="margin-right:2em;cursor:default;font-weight:bold"><?php echo cfCaption('genPort');?> (UDP)</span><input name="wowPort" type="text" size="1" value="<?php echo $wowPort;?>" onkeyup="checkAll()" maxlength="5">
  484. </div>
  485. <br>
  486.  
  487. <?php
  488.  
  489. /**
  490.  * Network adapters list
  491.  */
  492. echo outDivFrame('frame2').'<div class="frame2Header">'.cfCaption('configWOWAdapters').'</div>';
  493. echo '<select name="wowAdapter" onchange="adapterChanged()" style="width:400px">';
  494. $other=true;
  495. foreach ($adapters as $mac=>$adapter){
  496.     if($mac==$wowMac) $other=false;
  497.     echo '<option value="'.$mac.'" '.(($mac==$wowMac)?'selected':'').'>'.cfUTF8Encode($adapter['name']).'</option>';
  498. }
  499. echo '<option value="other" '.(($other)?'selected':'').'>'.cfCaption('userNewIcon').'</option>';
  500. ?>
  501. </select>
  502. <br><b>MAC   </b>
  503. <?php
  504.  
  505. /**
  506.  * MAC input
  507.  */
  508. $mac=explode('-',$wowMac);
  509. for($i=0;$i<6;$i++) echo '<input type="text" name="wowMac'.$i.'" value="'.trim($mac[$i]).'" maxlength="2" style="width:2em;text-align:center" '.(($other)?'':'disabled="disabled"').' onchange="macChanged()" onkeyup="macChanged()">'.(($i<5)?' - ':'');
  510. ?>
  511. </div>
  512. <br>
  513. <center>
  514. <?php
  515. /**
  516.  * Buttons
  517.  */
  518.  
  519. // Config ok ?
  520. if(!$wowEnabled || ($wowMac!='  -  -  -  -  -  ' && (!$wowUseHost || checkHost($wowHost)))) $state='up'; else $state='off';
  521.  
  522. // Test
  523. echo outDivFrame('frame2');
  524. echo outButton(cfCaption('genTest'),'javascript:void(wowTest())',outIcon('wowTest'),false,'testBt');
  525. echo '   ';
  526.  
  527. // Full test
  528. echo outButton(cfCaption('genTestFull').'...','javascript:void(wowTestFull())',outIcon('wowTestFull'),false,'testFullBt');
  529. echo '</div><br>';
  530.  
  531. // Save/apply
  532. echo outButton(cfCaption('genValidate'),'javascript:validate()',outIcon('ok'),false,'validateBt');
  533. echo '   ';
  534.  
  535. // Cancel
  536. echo outButton(cfCaption('genCancel'),'javascript:wl.UICommand(\'close\')',outIcon('cancel'),false,'cancelBt');
  537. ?>
  538. <br> 
  539. </center>
  540. </div>
  541. </div>
  542.  
  543. <div id="maskDiv" style="position:absolute;top:0;left:0;width:100%;height:100%;background:black;display:none;z-index:1000"></div>
  544.  
  545. <?php
  546. /**
  547.  * WOW Test frame
  548.  */
  549. ?>
  550. <div id="testFrame" style="position:absolute;top:30%;left:50%;width:50%;display:none;z-index:1001">
  551.     <div class="popup" style="position:relative;width:300px;left:-150px;margin-right:-150px">
  552.         <div class="popupHeader"><?php echo cfCaption('genTest');?></div>
  553.         <br>
  554.         <center>
  555.         <?php echo outImage(outIcon('loading'),false,'id="wowTestLoadingIcon"','vertical-align:middle');?>
  556.         <?php echo outImage(outIcon('loading'),false,'id="wowTestResultIcon"','vertical-align:middle;display:none');?>
  557.         <span id="testResult" style="margin-left:2em;margin-right:2em"></span><br><br><br>
  558.         <?php echo outButton(cfCaption('genClose'),'javascript:hideTestFrame()',outIcon('close')); ?>
  559.         </center>
  560.         <br>
  561.     </div>
  562. </div>
  563.  
  564.  
  565. <?php
  566. /**
  567.  * WOW Full Test frame
  568.  */
  569. ?>
  570. <div id="testFullFrame" style="position:absolute;top:10%;left:50%;width:50%;display:none;z-index:1001">
  571.     <div class="popup" style="position:relative;width:300px;left:-150px;margin-right:-150px">
  572.         <div class="popupHeader"><?php echo cfCaption('genTestFull');?></div>
  573.             <br><div style="text-align:justify">
  574.             <?php
  575.             $icon=outImage(outIcon('warning'),false,false,'float:left:padding-bottom:2em;margin-right:1em');
  576.             echo str_replace('<b>',$icon.'<b>',cfCaption('wowTestFullText'));
  577.             ?><br clear="all">
  578.             <br>
  579.             <br>
  580.             <center>
  581.             <?php echo outButton(cfCaption('genOK'),'javascript:fullTestRun()',outIcon('wowTestFull')); ?>
  582.                
  583.             <?php echo outButton(cfCaption('genCancel'),'javascript:fullTestCancel()',outIcon('cancel')); ?>
  584.             </center>
  585.             <br>
  586.         </div>
  587.     </div>
  588. </div>
  589. <script type="text/javascript">checkAll()</script>
  590. </form>
  591. </body>